/*
 * @Author: “FrozenX”
 * @LastEditors: baoyiwen 511530203@qq.com
 * @Date: 2022-11-10 13:35:28
 * @LastEditTime: 2025-04-25 17:02:08
 * @Description: 国密加密解密工具类
 */
import smCrypto from "sm-crypto";
const sm2 = smCrypto.sm2;
const cipherMode = 1; // 1 - C1C3C2，0 - C1C2C3，默认为1
const publicKey =
  "04298364ec840088475eae92a591e01284d1abefcda348b47eb324bb521bb03b0b2a5bc393f6b71dabb8f15c99a0050818b56b23f31743b93df9cf8948f15ddb54";
/**
 * 国密加解密工具类
 */

const BmpSM = {
  ...smCrypto,
  /**
   * SM2加密
   */
  doSm2Encrypt(msgString) {
    return sm2.doEncrypt(msgString, publicKey, cipherMode);
  },
  /**
   * SM2解密
   */
  doSm2Decrypt(encryptData, privateKey) {
    // return encryptData
    return sm2.doDecrypt(encryptData, privateKey, cipherMode);
  },
};
export default BmpSM;
